package com.xca.znb.model.impl;

import android.content.Context;

import com.xca.znb.database.UserDAO;
import com.xca.znb.entity.Message;
import com.xca.znb.entity.NewsLetter;
import com.xca.znb.entity.User;
import com.xca.znb.model.imodel.IMessage;

import java.util.List;

public class MessageImpl implements IMessage {
    private UserDAO userDAO ;
    public MessageImpl(Context context){
        userDAO = new UserDAO(context);
    }
    @Override
    public void sendMessage(String sendId, String receiveId, String text, String time) {
        userDAO.addMessage(sendId, receiveId, text, time);
    }

    @Override
    public List<Message> getMessage() {
        return userDAO.getMessage();
    }

    @Override
    public User getUserByPhone(String phone) {
        return userDAO.getUser(phone);
    }

    @Override
    public NewsLetter getNewsletterByPhone(String phone1, String phone2) {
        return userDAO.getNewsletterByPhone(phone1, phone2);
    }

    @Override
    public void updateNewsletterTimeByPhone(String phone1, String phone2, String time) {
        userDAO.updateNewsletterTime(phone1, phone2, time);
    }
}
